<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目管理列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">

<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
<!--                    <input type="hidden" id="deptId" name="deptId">-->
<!--                    <input type="hidden" id="parentId" name="parentId">-->
                    <div class="select-list">
                        <ul>
                            <li>
                                <input type="text" name="project_name"/>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="cms:knowledgemanagement:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>

            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:user:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:user:remove')}]];
    // var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]];
    var prefix = ctx + "knowledgemanagement/knowledgeBenchmarking";

    $(function() {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({ initClosed: panehHidden, west__size: 185 });
        queryUserList();
        // queryDeptTree();
    });

    function queryUserList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            detailUrl : prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            sortName: "project_id",
            sortOrder: "asc",
            modalName: "用户",
            columns: [{
                checkbox: true
            },
                {
                    field: 'project_id',
                    title: '项目ID',
                    align: "center",
                },
                {
                    field: 'project_name',
                    title: '项目名称',
                    align: "center",
                },

                {
                    field: 'project_start',
                    title: '开始时间',
                    align: "center",
                },
                {
                    field: 'project_end',
                    title: '结束时间',
                    align: "center",
                },
                {
                    field: 'project_info',
                    title: '项目简介',
                    align: "center",
                },
                {
                    field: 'project_file',
                    title: '附件',
                    align: "center",
                },
                {
                    field: 'project_status',
                    title: '是否为标杆文件',
                    align: "center",
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    field: 'project_type',
                    title: '类别',
                    align: "center",
                    formatter: function (value, row, index) {
                        if (row.project_type == 1) {
                            return "硬装项目";
                        } else {
                            return "软装项目";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.project_id + '\')"><i class="fa fa-search"></i></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }

    /* 角色状态显示 */
    function statusTools(row) {
        if (row.project_status == 0) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.project_id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.project_id + '\')"></i> ';
        }
    }

    /* 角色管理-停用 */
    function disable(project_id) {
        $.modal.confirm("确认要取消标杆项目吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "project_id": project_id, "project_status": 0 });
        })
    }

    /* 角色管理启用 */
    function enable(project_id) {
        $.modal.confirm("确认要启用角色吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "project_id": project_id, "project_status": 1 });
        })
    }

</script>
</body>
</html>
